Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iterating over children in form builder #6694

Merged
merged 3 commits into from
Dec 11, 2020

Conversation

franmomu
Copy link
Member

@franmomu franmomu commented Dec 10, 2020

Subject

Triggered by #6689 (comment)

AdminHelper::getChildFormBuilder() method was iterating only over the first level of form builder. It is needed a
RecursiveIteratorIterator for a tree traversal as AdminHelper::getChildFormView() method does.

It also fixes FormBuilderIterator prefix property when traversing children, now the current prefix is passed to the
children to create its key.

I am targeting this branch, because this is a bugfix.

Changelog

### Deprecated
- Deprecated passing other type than `string` or `null` as argument 2 constructing `FormBuilderIterator`.
### Fixed
- Fixed iterating over children names in `AdminHelper::getChildFormBuilder` recursively.

When merging with 4.x, https://github.com/sonata-project/SonataAdminBundle/pull/6533/files#diff-743b4f55ec26cc7163d9150b5f5e8f1b40a0fbd4338f84b36dc2067ab3507b98L88 should be reverted (add $this->key() argument).

PS: The variable change from $formBuilder to $currentFormBuilder is because $formBuilder is the name of the parameter in the function.

AdminHelper::getChildFormBuilder() method was iterating only
over the first level of form builder. It is needed a
RecursiveIteratorIterator for a tree traversal as
AdminHelper::getChildFormView() method does.

It also fixes FormBuilderIterator prefix property when
traversing children, now the current prefix is passed to the
children to create its key.
@franmomu franmomu added the patch label Dec 10, 2020
@franmomu franmomu requested a review from a team December 10, 2020 19:29
@franmomu franmomu added minor and removed patch labels Dec 10, 2020
@franmomu franmomu force-pushed the fix_form_builder_iterator branch from c471efd to e6616fc Compare December 10, 2020 19:47
VincentLanglet
VincentLanglet previously approved these changes Dec 10, 2020
@VincentLanglet VincentLanglet requested a review from a team December 10, 2020 21:15
Changes mocks from stubs when these mocks do not have any
expectation.
@franmomu franmomu force-pushed the fix_form_builder_iterator branch from 993c95b to 47afea9 Compare December 11, 2020 08:08
@franmomu franmomu requested a review from greg0ire December 11, 2020 10:29
@greg0ire greg0ire merged commit ecab714 into sonata-project:3.x Dec 11, 2020
@greg0ire
Copy link
Contributor

Thanks @franmomu !

@franmomu franmomu deleted the fix_form_builder_iterator branch December 11, 2020 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants